part of 'login_bloc.dart';

abstract class LoginEvent extends BaseEvent<LoginBloc, LoginState> {}

class PhoneLoginEvent extends LoginEvent {
  final String phone;
  final String code;

  PhoneLoginEvent(this.phone, this.code);

  @override
  Future<LoginState> on(LoginBloc bloc, LoginState currentState) async {
    showLoading();
    final bean = await PhoneLoginRequest(phone, code).request();
    isSuccess(bloc, bean);
    AppData.setToken(bean.data);
    UserBloc.instance.getUserInfo();

    dismissLoading();
    RouterUtil.instance.pop(Bundle().withBool('result', true));
    return currentState;
  }
}
